﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>major_changeInsert</title>
    <script src="~/lib/axios/dist/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-card class="box-card">
                <el-main>
                    <el-form ref="form" :model="form" :rules="rules" label-width="80px" :inline="true" size="mini">
                        <el-form-item label="档案编号" prop="human_id">
                            <el-input v-model="form.human_id" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="姓名" prop="human_name">
                            <el-input v-model="form.human_name" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原I级机构名称" prop="first_kind_name" label-width="101px">
                            <el-input v-model="form.first_kind_name" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原II级机构名称" prop="second_kind_name" label-width="105px">
                            <el-input v-model="form.second_kind_name" style="width: 207px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原III级机构名称" prop="third_kind_name" label-width="109px">
                            <el-input v-model="form.third_kind_name" style="width: 156px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原职位分类名称" prop="major_kind_name" label-width="110px">
                            <el-input v-model="form.major_kind_name" style="width: 156px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原职位名称" prop="major_name" label-width="88px">
                            <el-input v-model="form.major_name" style="width: 199px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原薪酬标准" prop="salary_standard_name" label-width="82px">
                            <el-input v-model="form.salary_standard_name" style="width: 230px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="原薪酬总额" prop="salary_sum" label-width="82px">
                            <el-input v-model="form.salary_sum" style="width: 183px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="新机构名称" prop="value" label-width="93px">
                            <div class="block">
                                <el-cascader v-model="form.value"
                                             :options="form._list"
                                             ref="cascaderAddr"
                                             style="width: 173px "
                                             @@change="adminSelect"></el-cascader>
                            </div>
                        </el-form-item>
                        <el-form-item label="新职位分类" prop="values" label-width="93px">
                            <div class="block">
                                <el-cascader v-model="form.values"
                                             :options="form._list1"
                                             ref="cascaderAddr1"
                                             style="width: 195px "
                                             @@change="adminSelect1"></el-cascader>
                            </div>
                        </el-form-item>
                        <el-form-item label="新薪酬标准" prop="salary_standard_idT" label-width="93px">
                            <template>
                                <el-select v-model="form.salary_standard_idT" placeholder="请选择薪酬" style="width: 218px "
                                           @@change="selectGet">
                                    <el-option v-for="item in list2"
                                               :key="item.ssd_id"
                                               :label="item.standard_name"
                                               :value="item.ssd_id">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="新薪酬总额" prop="new_salary_sum" label-width="82px">
                            <el-input v-model="form.new_salary_sum" style="width: 183px "></el-input>
                        </el-form-item>
                        <el-form-item label="登记人" prop="register" label-width="80px">
                            <template>
                                <el-select v-model="form.register" placeholder="请选择登记人" style="width: 186px ">
                                    <el-option v-for="item in listm"
                                               :key="item.u_id"
                                               :label="item.u_true_name"
                                               :value="item.u_true_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item prop="regist_time" label="登记时间">
                            <el-date-picker style="width: 208px " :disabled="true" type="datetime" placeholder="选择日期" v-model="form.regist_time"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="调动原因" prop="change_reason">
                            <el-input type="textarea" v-model="form.change_reason" style="width: 1094px;"></el-input>
                        </el-form-item>
                        <el-form-item class="_klpo">
                            <template>
                                <el-button type="primary" @@click="insert('form')">提交</el-button>
                            </template>
                            <el-button @@click="resetForm()">返回</el-button>
                        </el-form-item>
                    </el-form>
                </el-main>
                </el-card>
        </el-container>
    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                list2: [],//薪酬
                listm: [],//用户
                form: {
                    salary_standard_idT: '',
                    value: [],
                    values:[],
                    huf_id: '',
                    human_id: '',
                    first_kind_id: '',
                    first_kind_name: '',
                    second_kind_id: '',
                    second_kind_name: '',
                    third_kind_id: '',
                    third_kind_name: '',
                    human_name: '',
                    major_kind_id: '',
                    major_kind_name: '',
                    major_id:'',
                    major_name:'',
                    salary_standard_id: '',
                    salary_standard_name: '',
                    salary_sum: '',
                    new_first_kind_id: '',
                    new_first_kind_name: '',
                    new_second_kind_id: '',
                    new_second_kind_name: '',
                    new_third_kind_id: '',
                    new_third_kind_name: '',
                    new_major_kind_id: '',
                    new_major_kind_name: '',
                    new_major_id: '',
                    new_major_name: '',
                    new_salary_standard_id: '',
                    new_salary_standard_name: '',
                    new_salary_sum: '',
                    change_reason: '',
                    register: '',
                    regist_time: '',
                },
                rules: {
                    value: [
                        { required: true, message: '请选择机构', trigger: 'change' }
                    ],
                    values: [
                        { required: true, message: '请选择职位', trigger: 'change' }
                    ],
                    salary_standard_idT: [
                        { required: true, message: '请选择薪酬标准', trigger: 'change' }
                    ],
                    register: [
                        { required: true, message: '请选择登记人', trigger: 'change' }
                    ],
                    change_reason: [
                        { required: true, message: '请填写调动原因', trigger: 'blur' }
                    ],
                },
            },
            methods: {
                insert(formName) {
                    //表单验证
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将提交, 是否提交?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                this.inse();
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消提交'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                inse() {
                    //调动添加
                    axios.get('/major_change/Insert', {
                        params: {
                            human_id: this.oid,
                            first_kind_id: this.form.first_kind_id,
                            first_kind_name: this.form.first_kind_name,
                            second_kind_id: this.form.second_kind_id,
                            second_kind_name: this.form.second_kind_name,
                            third_kind_id: this.form.third_kind_id,
                            third_kind_name: this.form.third_kind_name,
                            major_kind_id: this.form.major_kind_id,
                            major_kind_name: this.form.major_kind_name,
                            major_id: this.form.major_id,
                            major_name: this.form.major_name,
                            new_first_kind_id: this.form.new_first_kind_id,
                            new_first_kind_name: this.form.new_first_kind_name,
                            new_second_kind_id: this.form.new_second_kind_id,
                            new_second_kind_name: this.form.new_second_kind_name,
                            new_third_kind_id: this.form.new_third_kind_id,
                            new_third_kind_name: this.form.new_third_kind_name,
                            new_major_kind_id: this.form.new_major_kind_id,
                            new_major_kind_name: this.form.new_major_kind_name,
                            new_major_id: this.form.new_major_id,
                            new_major_name: this.form.new_major_name,
                            human_id: this.form.human_id,
                            human_name: this.form.human_name,
                            salary_standard_id: this.form.salary_standard_id,
                            salary_standard_name: this.form.salary_standard_name,
                            salary_sum: this.form.salary_sum,
                            new_salary_standard_id: this.form.new_salary_standard_id,
                            new_salary_standard_name: this.form.new_salary_standard_name,
                            new_salary_sum: this.form.new_salary_sum,
                            change_reason: this.form.change_reason,
                            check_reason: this.form.check_reason,
                            register: this.form.register,
                            regist_time: this.form.regist_time,
                        }
                    })
                        .then(res => {
                            console.info(res);
                              //人力资源机构职位变更
                            axios.get('/major_change/UpdateDd', {
                                params: {
                                    huf_id: @ViewBag.huf_id,
                                    major_change_amount: 1,
                                    human_file_status:11,
                                }
                            })
                                .then(res => {
                                    console.info(res);
                                    this.$message({
                                        type: 'success',
                                        message: '提交成功!'
                                    });
                                    this.resetForm();
                                })
                                .catch(err => {
                                    console.info(err);
                                });
                        })
                        .catch(err => {
                            console.info(err);
                        })
                },
                //薪酬变更事件
                selectGet(value) {
                    let obj = {};
                    obj = this.list2.find((item) => {
                        return item.ssd_id === value;
                    });
                    this.form.new_salary_standard_id = obj.standard_id;
                    this.form.new_salary_sum = obj.salary_sum;
                    this.form.new_salary_standard_name = obj.standard_name;
                },
                resetForm() {
                    location.href ="/major_change/major_change"
                },
                ent() {
                      //人力资源查询
                    axios.get('/major_change/Quers/' + @ViewBag.huf_id)
                        .then(res => {
                            console.info(res);
                            this.form.human_name = res.data.human_name;
                            this.form.human_id = res.data.human_id;
                            this.form.salary_sum = res.data.salary_sum;
                            this.form.salary_standard_id = res.data.salary_standard_id;
                            this.form.salary_standard_name = res.data.salary_standard_name;
                            this.form.first_kind_id = res.data.first_kind_id;
                            this.form.first_kind_name = res.data.first_kind_name;
                            this.form.second_kind_id = res.data.second_kind_id;
                            this.form.second_kind_name = res.data.second_kind_name;
                            this.form.third_kind_id = res.data.third_kind_id;
                            this.form.third_kind_name = res.data.third_kind_name;
                            this.form.major_kind_id = res.data.human_major_kind_id;
                            this.form.major_kind_name = res.data.human_major_kind_name;
                            this.form.major_id = res.data.human_major_id;
                            this.form.major_name = res.data.hunma_major_name;
                            this.form.salary_standard_id = res.data.salary_standard_id;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                fill() {
                    //机构查询
                    axios.get('/engage_major_release/Dg', {
                    })
                        .then(res => {
                            console.info(res);
                            this.form._list = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //职位查询
                    axios.get('/engage_major_release/Dgto', {
                    })
                        .then(res => {
                            console.info(res);
                            this.form._list1 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                     //薪酬标准查询
                    axios.get('/major_change/Querse', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list2 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //用户查询
                    axios.get('/users/que', {
                    })
                        .then(res => {
                            console.info(res);
                            this.listm = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    this.ent();
                },
                adminSelect(value, thsAreaCode) {
                    //获取组件名为cascaderAddr的选中节点的labe,pathlabes获取labe数组
                    var thsAreaCode = this.$refs.cascaderAddr.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.form.new_first_kind_id = forminsert[0];
                    this.form.new_second_kind_id = forminsert[1];
                    this.form.new_third_kind_id = forminsert[2];
                    this.form.new_first_kind_name = thsAreaCode[0];
                    this.form.new_second_kind_name = thsAreaCode[1];
                    this.form.new_third_kind_name = thsAreaCode[2];
                },
                adminSelect1(value, thsAreaCode) {
                    var thsAreaCode = this.$refs.cascaderAddr1.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.form.new_major_kind_id = forminsert[0];
                    this.form.new_major_id = forminsert[1];
                    this.form.new_major_kind_name = thsAreaCode[0];
                    this.form.new_major_name = thsAreaCode[1];
                },
                get() {
                    //当前时间
                    this.form.regist_time = new Date();
                },
            },
            mounted() {
                //时间计时器
                setInterval(this.get, 1000);
            },
            //可以对vue的数据和方法进行操作,不能对DOM进行操作
            created: function () {
                this.fill();
            }
        });
    </script>
    <style>
        .hide .el-upload--picture-card {
            display: none;
        }

        .kbl {
            width: 148px;
            height: 148px;
            overflow: hidden;
            float: right;
        }

        ._klpo {
            float: right;
        }
        .el-card__body {
            padding: 4px;
        }
    </style>
</body>
</html>
